package my;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableDiscoveryClient //开关，开启服务的注册与发现功能
public class App {
    public static void main(String[] args) {
        SpringApplication.run(App.class,args);
    }


    @Bean
    @LoadBalanced
    //让ribbon拦截RestTemplate发出的所有的请求
    //ribbon获取url中的service name
    //从nacos注册中⼼获取实例列表
    //负责从实例列表中通过相应的负载均衡算法，获取⼀个实例
    public RestTemplate initRestTemplate(){
        return new RestTemplate();
    }
}
